package leetcode.code0376;

import leetcode.IDebug;

public class Solution implements IDebug {

	public int wiggleMaxLength(int[] nums) {
		int len = nums.length;
		// [1,17,5,10,13,15,10,5,16,8]
		int[] d1 = new int[len];// 大
		int[] d2 = new int[len];// 小
		int ans = 0;
		for (int i = 0; i < len; i++) {
			int a1 = 0, a2 = 0;
			int ni = nums[i];
			for (int j = 0; j < i; j++) {
				int nj = nums[j];
				if (ni > nj) {
					a1 = Math.max(a1, d2[j]);
				} else if (ni < nj) {
					a2 = Math.max(a2, d1[j]);
				}
			}
			d1[i] = a1 + 1;
			d2[i] = a2 + 1;
			ans = Math.max(ans, Math.max(a1, a2) + 1);
		}
		return ans;
	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
